package com.bw.lib_core.mvp.view;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.bw.lib_core.mvp.presenter.IPresenter;

public abstract class BaseFragent<P extends IPresenter> extends Fragment implements IView,IFragment {
    protected View baseView;
    protected P pPresenter;
    @Override
    public View onCreateView( LayoutInflater inflater, ViewGroup container,  Bundle savedInstanceState) {
        return baseView=inflater.inflate(bandlayout(), container, false);
    }

    @Override
    public void onViewCreated(View view,Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initView();
        initData();
    }

    @Override
    public <T extends View> T findViewById(int id) {
        return baseView.findViewById(id);
    }

    @Override
    public void showToast(String msg) {

    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (pPresenter!=null){
            pPresenter.destory();
            pPresenter=null;
        }
    }
}
